home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- set -e
-
- MYNAME="$0"
-
- # $* message
- warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
-
- # $* message
- report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
-
- # Move a conffile without triggering a dpkg question
- mv_conffile() {
- OLDCONFFILE="$1"
- NEWCONFFILE="$2"
-
- if [ -e "$OLDCONFFILE" ]; then
- echo "Preserving user changes to $NEWCONFFILE"
- mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
- mv -f "$OLDCONFFILE" "$NEWCONFFILE"
- elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
- rm -f "$OLDCONFFILE".dpkg-bak
- fi
- }
-
- devfs_is_active()
- {
- test -e /dev/.devfsd
- }
-
- kernel_is_2_6_or_above()
- {
- case "$(uname -r)" in
- 1.*|2.[012345]*) return 1 ;;
- *) return 0 ;;
- esac
- }
-
- udev_is_active()
- {
- test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
- kernel_is_2_6_or_above || return 1
- return 0
- }
-
- case "$1" in
- configure|reconfigure)
- if dpkg --compare-versions "$2" lt "1.0.10-4ubuntu2"; then
- mv_conffile /etc/modprobe.d/alsa-base-blacklist \
- /etc/modprobe.d/blacklist-modem
-
- rmdir /etc/alsa/modprobe-post-install.d 2>/dev/null || true
-
- rm -f /etc/discover.d/alsa-base
- rmdir /etc/discover.d 2>/dev/null || true
-
- rm -f /etc/hotplug/blacklist.d/alsa-base
- rmdir /etc/hotplug/blacklist.d 2>/dev/null || true
-
- rm -f /etc/modutils/alsa-base
- rmdir /etc/modutils 2>/dev/null || true
-
- rm -f /etc/init.d/alsa
- fi
-
- # Remove old obsolete configuration files
- # (Keep this until etch)
- if [ -d /etc/sound ]; then
- rmdir /etc/sound 2> /dev/null || :
- fi
- rm -f \
- /etc/apm/event.d/alsa \
- /etc/apm/event.d/alsa.dpkg-old \
- /etc/default/alsa.debconf-backup \
- /etc/devfs/conf.d/alsa \
- /etc/discover.conf.d/10alsa \
- /etc/discover.conf.d/10alsa.dpkg-old \
- /etc/alsa/alsa-base.conf \
- /etc/alsa/modutils/0.5 \
- /etc/alsa/modutils/0.9 \
- /etc/alsa/modutils/1.0 \
- /etc/alsa/modutils/0.5.debconf-backup \
- /etc/alsa/modutils/0.9.debconf-backup \
- /etc/alsa/modutils/1.0.debconf-backup \
- /etc/alsa/modprobe-post-install.d/alsa-base \
- /etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
- /etc/modutils/alsa \
- /etc/modutils/alsa-path \
- /etc/modprobe.d/alsa \
- /etc/modprobe.d/sound
- # Delete hotplug blacklist backup file since hotplug doesn't ignore
- # it as it should (#299205)
- rm -f \
- /etc/hotplug/blacklist.d/alsa-base.dpkg-old
- # Delete obsolete rc symlinks to alsa init.d script
- # (update-rc.d produces an unnecessary warning message on stderr (see #164471) so print the error message only if its error status is nonzero)
- STDERR="$(update-rc.d -f alsa remove 2>&1 >/dev/null)" || echo "Warning: 'update-rc.d -f alsa remove' reported: '$STDERR'." >&2
-
- # Decide which conf file to read
- conf_file=""
- if [ -f /etc/default/alsa ] ; then
- conf_file=/etc/default/alsa
- elif [ -f /usr/share/alsa-base/alsa.default ] ; then
- conf_file=/usr/share/alsa-base/alsa.default
- else
- report_error "No configuration file found"
- exit 1
- fi
- # Read variables from conf file
- force_unload_modules_before_suspend="$(
- . "$conf_file" >/dev/null 2>&1
- echo "$force_unload_modules_before_suspend"
- )"
- # Write new conf file
- cat /usr/share/alsa-base/alsa.default | sed \
- -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
- > /etc/default/alsa
- # Set up apm symlinks
- [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
- # $1: file to check
- already_linked_to_alsa()
- {
- [ "$1" ] || return 1
- [ -L "$1" ] || return 1
- [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
- return 0
- }
- ALREADY_LINKED=no
- for F in /etc/apm/suspend.d/??alsa ; do
- already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
- done
- [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
- ALREADY_LINKED=no
- for F in /etc/apm/resume.d/??alsa ; do
- already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
- done
- [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- # We don't have to do anything because we didn't do anything in prerm
- exit 0
- ;;
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
-
-
-
-